package com.lzq.online_learning_system.comm;

import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.Map;

//全局异常处理器
@ControllerAdvice
public class GlobalExceptionHandler {
    @ExceptionHandler(Exception.class)
    @ResponseBody
    public Map<String,Object> handleException(Exception exception){
     Map<String,Object> map=new HashMap<>();
     map.put("Code",500);
     map.put("msg","请检查网络，连接到外星去了");
     return map;
    }
}
